Crate spmc

Source
Expand description

§SPMC

A single producer, multiple consumers. Commonly used to implement work-stealing.

§Example

let (mut tx, rx) = spmc::channel();

let mut handles = Vec::new();
for n in 0..5 {
    let rx = rx.clone();
    handles.push(thread::spawn(move || {
        let msg = rx.recv().unwrap();
        println!("worker {} recvd: {}", n, msg);
    }));
}

for i in 0..5 {
    tx.send(i * 2).unwrap();
}

for handle in handles {
  handle.join().unwrap();
}

Structs§

Enums§

Functions§